package com.unc.allergyex.objects.db;

import java.util.ArrayList;

import com.unc.allergyex.helpers.ObjManager;

/**
 * This class represents the Dish (menu item) database
 * object.  These objects should be created from 
 * the JSON restaurant/menu result string.
 * @author Phillip
 */
public class Dish {
	String name;
	String id;
	String[] componentIds;
	
	public Dish(String name, String id, String[] componentIds) {
		this.name = name;
		this.id = id;
		this.componentIds = componentIds;
	}

	public String getName() {
		return name;
	}

	public String getId() {
		return id;
	}
	
	public ArrayList<Component> getComponents(){
		return ObjManager.getComponentList(componentIds);
	}
	
	
	public boolean getAllergic(){
		if (componentIds != null){
			for (Component c : getComponents()){
				if (c.getAllergic()){
					return true;
				}
			}
		}
		return false;
	}
}
